package com.ruoyi.project.sysmanage.service.impl;

import com.ruoyi.project.sysmanage.domain.Dept;
import com.ruoyi.project.sysmanage.mapper.SysmMapper;
import com.ruoyi.project.sysmanage.service.SysmDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class SysmDeptServiceImpl implements SysmDeptService {
/*
* 根据查询条件查询数据库
* 分页逻辑使用pagehelper实现
*
* */
    @Autowired
    private SysmMapper sysMapper;
    @Override
    public List<Dept> findAll(Dept dept) {

        List<Dept> depts = sysMapper.selectAll(dept);

        return depts;
    }

    @Override
    public int addDept(Dept dept) {

        //考虑是否有数据需要赋值
        dept.setCreateTime(new Date());
        return sysMapper.insert(dept);
    }

    @Override
    public Dept getById(int deptId) {
        return sysMapper.selectById(deptId);
    }

    @Override
    public int updateDept(Dept dept) {

        dept.setUpdateTime(new Date());
        return sysMapper.update(dept);
    }

    @Override
    public int deleteDepts(int[] deptIds) {

        return sysMapper.delete(deptIds);
    }

    @Override
    public List<Dept> getAll() {

        return sysMapper.select();
    }
}
